<?php

require_once(dirname(__FILE__) . '/appconf.php');

class DbMove extends Site {

    function setup() {
        $this->run_modes('do');
        $this->start_mode('do');
        $this->selfurl = '/countBlog.php';
        $this->pagesize = 200;

        set_time_limit(0);
        ob_end_clean();
        ob_implicit_flush(true);

        parent::setup();
    }

    function cgiapp_prerun() {

        parent::cgiapp_prerun();
    }

    function action_do() {


        $param = array();
        $param['field'] = "";
        $param['where'] = "";
        $param['order'] = "mid desc";
        $param['group'] = "";
        $param['limit'] = "";
        $param['pagesize'] = "";
        $param['page'] = "";
        $param['join'] = "";
        $param['on'] = "";
        $data_terms_0 = db_query_hash('blog_users', $param);
        if ($data_terms_0['result']) {
            foreach ($data_terms_0['result'] as $value_terms) {

                $count_imore_blog = db_query_count('wp_' . $value_terms['bid'] . '_posts', " post_status='publish' and post_type='post'", IMOREBLOGDB);

                $count_itrial_blog = db_query_count('product_reports', " is_blog=1 and mid=" . $value_terms['mid']);

                echo "mid:" . $value_terms['mid'] . " itrial username:" . $value_terms['imore_name'] . " imore blog數量：" . $count_imore_blog . " itrial blog 數量：" . $count_itrial_blog ;
                if($count_imore_blog==$count_itrial_blog) echo " <span style='color:red'> 匹配</span>";
                echo "<br>";
            }
        }
    }

}

header("Content-type: text/html; charset=utf-8");
$webapp = new DbMove();
$webapp->run();
?>